<div class="panel panel-default panel-intro">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        {:build_toolbar(['refresh'])}
                        <a href="javascript:;" onclick="getNewOrder()" class="btn btn-success">匹配淘宝客新订单</a>
                        <a href="javascript:;" onclick="getSettlementOrder()" class="btn btn-success">匹配淘宝客结算订单</a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                           data-operate-edit="{:$auth->check('ordertbk/edit')}" 
                           data-operate-del="{:$auth->check('ordertbk/del')}" 
                           width="100%">
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>

<script>
    function getNewOrder(){
            $.ajax({
                url:"{$newUrl}",
                type: "GET",
                dataType:'json',
                async:false,
                success:function(result){
                    $.ajax({
                        url:"{:url('/api/tbk/tbkNewOrder')}",
                        type: "POST",
                        data: result,
                        dataType:'json',
                        async:false,
                        success:function(result){
                            console.log(result);
                            layer.msg(result.msg)
                        }
                    });
                },
                error: function(){
                    layer.alert('请先登录淘宝客帐号');
                }
            });
        }

        function getSettlementOrder(){
            $.ajax({
                url:"{$settlementUrl}",
                type: "GET",
                dataType:'json',
                async:false,
                success:function(result){
                    console.log(result);
                    $.ajax({
                        url:"{:url('/api/tbk/tbkSettlementOrder')}",
                        type: "POST",
                        data: result,
                        dataType:'json',
                        async:false,
                        success:function(result){
                            console.log(result);
                             layer.msg(result.msg)
                        }
                    });
                },
                error: function(){
                    layer.alert('请先登录淘宝客帐号');
                }
            });
        }
</script>